package com.sci.controller;

import com.sci.entity.Shipment;
import com.sci.service.ShipmentService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/shipment")
public class ShipmentController {

    @Resource
    private ShipmentService shipmentService;

    // 新增
    @PostMapping("/insert")
    public Boolean insert(@RequestBody Shipment shipment) {
        return shipmentService.insert(shipment);
    }

    // 根据ID删除
    @DeleteMapping("/delete/{id}")
    public Boolean deleteById(@PathVariable(value = "id") Integer id) {
        return shipmentService.deleteById(id);
    }

    // 根据ID修改
    @PutMapping("/update")
    public Boolean updateById(@RequestBody Shipment shipment) {
        return shipmentService.updateById(shipment);
    }

    // 根据wechat_id查询
    @GetMapping("/list/{wechatId}")
    public List<Shipment> selectByWechatId(@PathVariable(value = "wechatId") String wechatId) {
        return shipmentService.selectByWechatId(wechatId);
    }
}
